home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UScroller.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  8.1 KB  |  223 lines  |  [TEXT/MPS ]

  1. // UScroller.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __USCROLLER__
  5. #define __USCROLLER__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UGEOMETRY__
  10. #include "UGeometry.h"
  11. #endif
  12.  
  13. #ifndef __UVIEW__
  14. #include "UView.h"
  15. #endif
  16.  
  17.  
  18. //----------------------------------------------------------------------------------------
  19. // Forward and external class declarations. 
  20. //----------------------------------------------------------------------------------------
  21.  
  22. class TDocument;
  23. class TScrollerScrollBar;
  24. class TToolboxEvent;
  25.  
  26.  
  27. //----------------------------------------------------------------------------------------
  28. // TScroller: A view which can "scroll" its contents by translating coordinates.
  29. //----------------------------------------------------------------------------------------
  30.  
  31. class TScroller : public TView
  32. {
  33.     MA_DECLARE_CLASS;
  34.     
  35. public:
  36.     //------------------------------------------------------------------------------------
  37.     // Creation/Destruction Methods
  38.     //------------------------------------------------------------------------------------
  39.  
  40.     TScroller();
  41.         // Constructor
  42.         
  43.     void IScroller(TView* itsSuperView,
  44.                                   const VPoint& itsLocation,
  45.                                   const VPoint& itsSize,
  46.                                   SizeDeterminer itsHSizeDet,
  47.                                   SizeDeterminer itsVSizeDet,
  48.                                   const VPoint& itsMax,
  49.                                   Boolean wantHorzSBar,
  50.                                   Boolean wantVertSBar);
  51.         // Called to initialize a scroller procedurally.
  52.  
  53.     virtual void CreateScrollBar(VHSelect itsDirection);
  54.         // Called to create a scrollbar in 'itsDirection'.
  55.  
  56.     virtual TObject* Clone();
  57.         // calls Inherited::Clone and then clones owned objects
  58.  
  59.     virtual ~TScroller();
  60.         // If there are attached scrollbars frees them before calling Inherited::Free.
  61.  
  62.     //------------------------------------------------------------------------------------
  63.     // Standard signature support.
  64.     //------------------------------------------------------------------------------------
  65.  
  66.     virtual IDType GetStandardSignature();    // override 
  67.         // Returns this class's standard signature.
  68.  
  69.     //------------------------------------------------------------------------------------
  70.     // Stream I/O protocol support.
  71.     //------------------------------------------------------------------------------------
  72.  
  73.     virtual void ReadFields(TStream* aStream);    // override 
  74.     
  75.     virtual void WriteFields(TStream* aStream);    // override 
  76.  
  77.     //------------------------------------------------------------------------------------
  78.     // SubView Management Methods
  79.     //------------------------------------------------------------------------------------
  80.  
  81.     virtual void DoPostCreate(TDocument* itsDocument);
  82.         // Called in a post-order traversal of a newly-created view hierarchy
  83.         
  84.     virtual void AddedASubView(TView* theSubView);
  85.         // Calls Inherited::AddedASubView and then calls 'theSubView' to BeInScroller passing
  86.         // this as the scroller to be in.
  87.  
  88.     virtual void RemovedASubView(TView* theSubView);
  89.         // Calls BeInScroller with a parameter of NULL, for 'theSubView', before calling
  90.         // Inherited::RemovedASubView.
  91.  
  92.     virtual void ForceRedraw();
  93.         // Invalidates the entire view forcing a redraw.
  94.  
  95.  
  96.     //------------------------------------------------------------------------------------
  97.     // Size Methods
  98.     //------------------------------------------------------------------------------------
  99.  
  100.     virtual void SetFrame(const VRect& newFrame, Boolean invalidate);
  101.         // Resizes the scroller to newFrame, redrawing if 'invalidate' is true.
  102.  
  103.  
  104.     //------------------------------------------------------------------------------------
  105.     // Location Methods
  106.     //------------------------------------------------------------------------------------
  107.  
  108.     virtual void AdjustScrollLimits(Boolean drawScrollBars);
  109.         // Adjust the scrolling limits and redraws the scroll bars.
  110.  
  111.     virtual void AdjustScrollBars(Boolean invalidate);
  112.         // Resizes and re-Locates the scrollbars if required.
  113.  
  114.     virtual void SubViewChangedFrame(TView* theSubView,
  115.                                             const VRect& oldFrame,
  116.                                             const VRect& newFrame,
  117.                                             Boolean invalidate);
  118.         // Adjust the scroll limits based on the size change of the subviews.
  119.  
  120.     virtual void SetScrollLimits(const VPoint& scrollLimit,
  121.                                         Boolean drawScrollBars);
  122.         // Sets the scroll of the attached scrollbars, if there are any.
  123.  
  124.     virtual void SetScrollParameters(const VPoint& units,
  125.                                             Boolean horzConstraint,
  126.                                             Boolean vertConstraint);
  127.         // Sets up the fScrollUnit and fConstrain fields of the scroller.
  128.  
  129.  
  130.     //------------------------------------------------------------------------------------
  131.     // Scrolling Methods
  132.     //------------------------------------------------------------------------------------
  133.  
  134.     virtual void HaveScrollBar(TScrollerScrollBar* theScrollBar,
  135.                                       VHSelect direction);
  136.         // Sets the fScrollbar field in the given 'direction' to 'theScrollBar'.
  137.  
  138.     virtual void ScrollDraw(const VPoint& delta, Boolean invalidate);
  139.         // Method responsible for actually doing the scrolling by calling moving bits.
  140.         // Called by DoScroll.Invalidates newly revealed area if invalidate is true else
  141.         // updates the redraws the newly revealed area if invalidate is false. !!! NOTE
  142.         // this does not match the behaviour of other invalidate parameters because they
  143.         // interpret invalidate equals false to neither draw nor invalidate.Well we
  144.         // already know that the way that invalidate/ redraw/ don't-render control is
  145.         // handled needs _MAJOR_ overhauling anyways Sigh!
  146.  
  147.     virtual void DoScroll(const VPoint& delta, Boolean redraw);
  148.         // Method responsible for handling the scrolling, calls ScrollDraw if required.
  149.  
  150.     virtual VCoordinate ScrollStep(VHSelect vhs, short partCode);
  151.         // Depending on the 'partCode' returns the amount to be scrolled.
  152.  
  153.     virtual VCoordinate ScrollRelative(VHSelect vhs, VCoordinate sBarValue);
  154.         // Returns the relative amount to scroll.
  155.  
  156.     virtual void ScrollBy(const VPoint& delta, Boolean redraw);
  157.         // Called to scroll by 'deltaH & 'deltaV'.
  158.  
  159.     virtual void SetLocalOrigin(const VPoint& newOrigin, Boolean redraw);
  160.         // Sets the local origin.  Preserves bits by scrolling to the required coordinates.
  161.         // Calls ScrollBy
  162.  
  163.     virtual void AutoScroll(const VPoint& viewPt, VPoint& delta);
  164.         // Called during auto scrolling to return the delta to be scrolled.
  165.  
  166.     virtual void RevealRect(const VRect& rectToReveal,
  167.                                    const VPoint& minToSee,
  168.                                    Boolean redraw);
  169.         // Shows 'rectToReveal' with the minimum amount to be seen set to 'minToSee' by
  170.         // calling ScrollBy.
  171.  
  172. #if qDrag
  173.     
  174.     virtual VPoint GetDragScrollDelta(const VPoint& mouseInWindow);
  175.  
  176. #endif
  177.  
  178.  
  179.     //------------------------------------------------------------------------------------
  180.     // Miscellaneous Methods
  181.     //------------------------------------------------------------------------------------
  182.  
  183.     virtual void DoKeyEvent(TToolboxEvent* event);
  184.         // Handles when the Home, End, PageUp & PageDown keys are used.
  185.  
  186.     virtual TScroller* GetScroller(Boolean immediateSuperView);
  187.         // Returns this.
  188.  
  189.     //------------------------------------------------------------------------------------
  190.     // data members
  191.     //------------------------------------------------------------------------------------
  192.  
  193.     VRect fSBarOffsets;                            // how much to offset the associated
  194.                                                 // scroll bars from my bounds
  195.  
  196.     VPoint fScrollLimit;                        // the 'limit' of the subviews that should
  197.                                                 // be scrollable
  198.  
  199.     VPoint fMaxTranslation;                        // the computed maximum amount of
  200.                                                 // translation taking into account the
  201.                                                 // visible portion of the view. This keeps
  202.                                                 // us from scrolling the bottom of a view
  203.                                                 // to the top of a window
  204.  
  205.     VPoint fScrollUnit;                            // increment of scroll
  206.  
  207.     TScrollerScrollBar* fScrollBars[2];            // associated scroll bars if any
  208.  
  209.     IDType fScrollBarIdentifiers[2];            // associated scroll bars ids if any
  210.  
  211.     Boolean fConstrain[2];                        // should scrolling be constrained to a
  212.                                                 // multiple of my scrollunit
  213.  
  214.     Boolean fRespondsToFunctionKeys;            // if it responds to PgUp/ PgDn, etc.
  215.  
  216. };
  217.  
  218.  
  219.  
  220. #endif
  221.  
  222.  
  223.